package com.gxa.controller.commserve;

import com.gxa.common.utils.Result;
import com.gxa.entity.commserve.RepairRequestRecord;
import com.gxa.service.commserve.RepairRequestRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yjl
 * @since 2022-10-12 11:18:01
 */
@Api(tags = "用户报修记录")
@RestController
@RequestMapping("/repair-request-record")
public class RepairRequestRecordController {
    @Autowired
    private RepairRequestRecordService repairRequestRecordService;

//    List<RepairRequestRecord> repairRequestRecordList;
//    Date date = new Date("2022/10/11");
//    Repair repair = new Repair(1,"BX238198244","综合楼101室","打印机设备故障",date,date,0,"李四","12345678999",0);
//    public RepairRequestRecordController(){this.init();}
//    void init(){
//        repairRequestRecordList= new ArrayList<>();
//        RepairRequestRecord recruitmentRecord = new RepairRequestRecord(1,"发起报修","李四",date,repair,0);
//        repairRequestRecordList.add(recruitmentRecord);
//        RepairRequestRecord recruitmentRecord1 = new RepairRequestRecord(2,"发起报修","李四",date,repair,0);
//        repairRequestRecordList.add(recruitmentRecord1);
//    }


    @CrossOrigin(origins = "*",maxAge = 3600)//跨域请求配置
    @ApiOperation(value = "查询用户报修记录")
    @GetMapping("list/{id}")
    public Result list(@PathVariable("id") Integer id){
       try {
           List<RepairRequestRecord> repairRequestRecordList = this.repairRequestRecordService.queryList(id);
           Result<List<RepairRequestRecord>> result = Result.success(repairRequestRecordList);
           return result;
       }catch (Exception e){
           e.printStackTrace();
           return Result.failed("查询失败");
       }
    }







}
